Program to Calculate Body Mass Index (BMI)
The Body Mass Index (BMI) or Quetelet index is a value derived from the mass (weight) and height of an individual, male or female. The BMI is defined as the body mass divided by the square of the body height and is universally expressed in units of kg/m2, resulting from the mass in kilograms and height in meters. The formula is:...
read more
Find the distance covered to collect items at equal distances
A race is going on in which several stones are placed on a road. A bucket is placed at the starting point of the race, which is 5 units away from the first stone. The other stones are 3 units apart from each other and lie straight in a line one after another. I.e., the distance between 1st and 2nd stone is 3 units, between 3rd and 4th stone, it is also 3 units and so on. The competitor starts from the bucket, picks up the nearest stone, goes back and puts that stone into the bucket, then runs again to collect the next nearest stone, runs back, and puts it in the bucket. This way the process is continued till all the stones have been put into the bucket.Now if there are n stones lying on the ground, how much distance will be covered by the competitor in completing the whole process....
read more
Find largest sum of digits in all divisors of n
Given an integer number n, find the largest sum of digits in all divisors of n....
read more
Recursive Linear Search Algorithm
Linear Search is defined as a sequential search algorithm that starts at one end and goes through each element of a list until the desired element is found, otherwise the search continues till the end of the data set....
read more
Print powers using Anonymous Function in Python
Prerequisite : Anonymous function In the program below, we have used anonymous (lambda) function inside the map() built-in function to find the powers of 2. In Python, anonymous function is defined without a name. While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambda keyword. Hence, anonymous functions are also called lambda functions. Syntax:...
read more
Program to print 2D shapes
Take the user choice and print 2D shapes based on the choice. A shape with only two dimensions (such as width and height) and no thickness. Squares, Circles, Triangles etc are two dimensional objects. These shapes mostly contain mathematical figures such are a line, square, triangle, rectangle and hexagon. The shapes are given below :...
read more
Find the Target number in an Array
Finding a number within an array is an operation, in the field of computer science and data analysis. In this article, we will discuss the steps involved and analyze their time and space complexities....
read more
Program to print hollow pyramid, diamond pattern and their modifications
For Prerequisite : Loops, If Else Statement1. Hollow pyramid/triangle pattern The pattern is similar to pyramid pattern. The only difference is, we will replace all internal ‘#’ or ‘*’ characters by space character and we will print 2*N-1 (N = number of rows in pattern) ‘#’ or ‘*’ characters in last row. Examples:...
read more
Calculate speed, distance and time
When an object moves in a straight line at a steady speed, we can calculate its speed if we know how far it travels and how long it takes. This equation shows the relationship between speed, distance travelled and time taken: Speed is distance divided by the time taken. For example, a car travels 30 kilometres in 2 hours. Its speed is 30 ÷ 2 = 15km/hr....
read more
Sum of series M/1 + (M+P)/2 + (M+2*P)/4 + (M+3*P)/8……up to infinite
Find the sum of series M/1 + (M+P)/2 + (M+2*P)/4 + (M+3*P)/8……up to infinite where M and P are positive integers....
read more
Hollow lower triangular pattern
Given the value of n, i.e, the number of rows/columns for a square, print the pattern.Examples :...
read more
C Program to Check for Palindrome String
A string is said to be palindrome if the reverse of the string is the same as the string. For example, “abba” is a palindrome because the reverse of “abba” will be equal to “abba” so both of these strings are equal and are said to be a palindrome, but “abbc” is not a palindrome....
read more